package com.atguigu.yygh.hosp.controller.api;

import com.atguigu.yygh.common.result.Result;
import com.atguigu.yygh.hosp.service.DepartmentService;
import com.atguigu.yygh.model.hosp.Department;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Page;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/*==================================
      时 间:   2023-03-20
      讲 师:   刘  辉
      描 述:   尚硅谷教学团队
===================================*/
@RestController
@RequestMapping("/api/hosp")
public class ApiDepartmentController {
    @Autowired
    private DepartmentService departmentService;

    @PostMapping("/saveDepartment")
    public Result saveDepartment(Department department,String sign){
        //1.signkey校验：
        //2.保存科室信息
        departmentService.saveDepartment(department);
        return Result.ok();
    }

    @PostMapping("/department/list")
    public Result getDepartmentPage(String hoscode,Integer page,Integer limit){
        //1.signkey校验：
        //2.查询科室分页信息
        Page<Department> departmentPage= departmentService.getDepartmentPage(hoscode,page,limit);
        return Result.ok(departmentPage);
    }

    //根据医院编号和科室编号科室删除
    @PostMapping("/department/remove")
    public Result removeDepartment(String hoscode,String depcode){
    //1.sign校验
    //2.删除科室
        departmentService.removeDepartment(hoscode,depcode);
        return Result.ok();
    }
}
